local db = TUNING.MOD_AVATAR_BH_MOBIUS.badge.bh_mobius_energy

---@class components
---@field bh_mobius_energy component_bh_mobius_energy

local function on_val(self, value)
    self.inst.replica.bh_mobius_energy:SetVal(value)
end

---@class component_bh_mobius_energy
---@field inst ent
---@field val number # 能量值
local bh_mobius_energy = Class(

---@param self component_bh_mobius_energy
---@param inst ent
function(self, inst)
    self.inst = inst
    self.val = 0


end,
nil,
{
    val = on_val,
})

function bh_mobius_energy:OnSave()
    return {
        val = self.val
    }
end

function bh_mobius_energy:OnLoad(data)
    self.val = data.val or 0
end

function bh_mobius_energy:DoDelta(delta)
    self.val = math.clamp(self.val + delta, 0, db.max)
end

function bh_mobius_energy:IsMax()
    return self.val >= db.max
end

function bh_mobius_energy:GetVal()
    return self.val
end

return bh_mobius_energy